
## first
MyIP=192.168.100.201 #local_ip使用

开启route 
openstack-config --set /etc/neutron/neutron.conf DEFAULT service_plugins router

openstack-config --set /etc/neutron/plugins/ml2/ml2_conf.ini ml2 tenant_network_types vxlan
openstack-config --set /etc/neutron/plugins/ml2/ml2_conf.ini ml2 type_drivers flat,vlan,vxlan
openstack-config --set /etc/neutron/plugins/ml2/ml2_conf.ini ml2 mechanism_drivers linuxbridge,l2population
openstack-config --set /etc/neutron/plugins/ml2/ml2_conf.ini ml2_type_vxlan vni_ranges 3001:4000

openstack-config --set /etc/neutron/plugins/ml2/linuxbridge_agent.ini vxlan enable_vxlan true
openstack-config --set /etc/neutron/plugins/ml2/linuxbridge_agent.ini vxlan l2_population true
openstack-config --set /etc/neutron/plugins/ml2/linuxbridge_agent.ini vxlan local_ip $MyIP

openstack-config --set /etc/neutron/l3_agent.ini DEFAULT interface_driver linuxbridge

#启用L3
systemctl enable neutron-l3-agent.service
systemctl restart neutron-l3-agent.service
#服务重启
systemctl restart neutron-server
systemctl restart neutron-linuxbridge-agent

#计算节点

MyIP=10.2.1.17 #local_ip使用

openstack-config --set /etc/neutron/plugins/ml2/linuxbridge_agent.ini vxlan enable_vxlan true
openstack-config --set /etc/neutron/plugins/ml2/linuxbridge_agent.ini vxlan l2_population true
openstack-config --set /etc/neutron/plugins/ml2/linuxbridge_agent.ini vxlan local_ip $MyIP

#重启服务
systemctl restart neutron-linuxbridge-agent



## 创建公网

openstack network create  --share --external \
--provider-network-type flat --provider-physical-network external \
  ext-net

openstack subnet create --network ext-net \
--allocation-pool start=192.168.0.10,end=192.168.0.90 \
--dns-nameserver 61.128.128.68 --dns-nameserver 114.114.114.114 \
--gateway 192.168.0.1 --subnet-range 192.168.0.0/24 \
  ext-subnet

内网网络
#neutron net-create private --provider:network_type vxlan --router:external False --shared
openstack network create --share --internal --provider-network-type vlan innobase
#neutron subnet-create private --name private-subnet --gateway 192.168.1.1 192.168.1.0/24
openstack subnet create --network innobase \
--allocation-pool start=10.3.27.2,end=10.3.27.254 \
--gateway=10.3.27.1  --subnet-range 10.3.27.0/24 \
innobase-tech

openstack router create router-ext
# second

on controller node
echo '
net.ipv4.ip_forward = 1
net.ipv4.conf.default.rp_filter = 0
net.ipv4.conf.all.rp_filter = 0
'>>/etc/sysctl.conf
sysctl -p


cp /etc/neutron/neutron.conf{,.vxlan}
cp /etc/neutron/plugins/ml2/ml2_conf.ini{,.vxlan}
cp /etc/neutron/plugins/ml2/linuxbridge_agent.ini{,.vxlan}
cp /etc/neutron/l3_agent.ini{,.vxlan}
cp /etc/neutron/dhcp_agent.ini{,.vxlan}
cp /etc/nova/nova.conf{,.vxlan}
TUNNEL_IP=192.168.100.201
settingfile=/etc/neutron/neutron.conf
openstack-config --set $settingfile DEFAULT service_plugins router
openstack-config --set $settingfile DEFAULT allow_overlapping_ips True
openstack-config --set $settingfile DEFAULT router_scheduler_driver neutron.scheduler.l3_agent_scheduler.ChanceScheduler
openstack-config --set $settingfile DEFAULT l3_ha True
openstack-config --set $settingfile DEFAULT allow_automatic_l3agent_failover True
openstack-config --set $settingfile DEFAULT max_l3_agents_per_router 3
openstack-config --set $settingfile DEFAULT min_l3_agents_per_router 2
openstack-config --set $settingfile DEFAULT dhcp_agents_per_network 2

# or neutron.scheduler.l3_agent_scheduler.ChanceScheduler

settingfile=/etc/neutron/plugins/ml2/ml2_conf.ini
openstack-config --set $settingfile ml2 type_drivers flat,vlan,vxlan
openstack-config --set $settingfile ml2 mechanism_drivers linuxbridge,l2population
openstack-config --set $settingfile ml2 extension_drivers port_security
openstack-config --set $settingfile ml2 tenant_network_types vxlan
openstack-config --set $settingfile ml2 path_mtu 1500
openstack-config --set $settingfile ml2_type_flat flat_networks provider
openstack-config --set $settingfile ml2_type_vxlan vni_ranges 3001:4000
openstack-config --set $settingfile securitygroup enable_ipset True

settingfile=/etc/neutron/plugins/ml2/linuxbridge_agent.ini
openstack-config --set $settingfile linux_bridge physical_interface_mappings provider:eth1
openstack-config --set $settingfile vxlan enable_vxlan True
openstack-config --set $settingfile vxlan local_ip $TUNNEL_IP
openstack-config --set $settingfile vxlan l2_population True
openstack-config --set $settingfile agent prevent_arp_spoofing True
openstack-config --set $settingfile securitygroup enable_security_group True
openstack-config --set $settingfile securitygroup firewall_driver neutron.agent.linux.iptables_firewall.IptablesFirewallDriver

settingfile=/etc/neutron/l3_agent.ini
openstack-config --set $settingfile DEFAULT interface_driver neutron.agent.linux.interface.BridgeInterfaceDriver
openstack-config --set $settingfile DEFAULT external_network_bridge
openstack-config --set $settingfile DEFAULT debug false

settingfile=/etc/neutron/dhcp_agent.ini
openstack-config --set $settingfile DEFAULT interface_driver neutron.agent.linux.interface.BridgeInterfaceDriver
openstack-config --set $settingfile DEFAULT dhcp_driver neutron.agent.linux.dhcp.Dnsmasq
openstack-config --set $settingfile DEFAULT enable_isolated_metadata True
# openstack-config --set $settingfile DEFAULT verbose True


???
settingfile=/etc/nova/nova.conf
openstack-config --set $settingfile neutron url http://controller:9696
openstack-config --set $settingfile neutron auth_url http://controller:35357
openstack-config --set $settingfile neutron auth_type password
openstack-config --set $settingfile neutron project_domain_id default
openstack-config --set $settingfile neutron user_domain_id default
openstack-config --set $settingfile neutron region_name RegionOne
openstack-config --set $settingfile neutron project_name service
openstack-config --set $settingfile neutron username neutron
openstack-config --set $settingfile neutron password neutron
openstack-config --set $settingfile neutron service_metadata_proxy True
openstack-config --set $settingfile neutron metadata_proxy_shared_secret metadata


echo "dhcp-option-force=26,1450" >/etc/neutron/dnsmasq-neutron.conf

#启用L3
systemctl enable neutron-l3-agent.service
systemctl restart neutron-l3-agent.service

systemctl restart neutron-server.service  neutron-dhcp-agent.service neutron-metadata-agent.service
systemctl restart neutron-l3-agent.service
systemctl restart neutron-linuxbridge-agent.service

systemctl status neutron-server.service neutron-linuxbridge-agent.service neutron-dhcp-agent.service neutron-metadata-agent.service
systemctl status neutron-l3-agent.service

